package com.tc.quartz.server.exception;


import com.tc.quartz.server.core.StatusEnum;

import java.util.Arrays;

/**
 * 定时器异常类
 * @author yongjin.ye
 *
 */
public class JobRunException extends RuntimeException {

	private static final long serialVersionUID = -4347372765609175884L;
	
	private String code;
	private String message;

	public JobRunException() {
		super("定时器异常");
	}

	public JobRunException(String code) {
		super(String.format("定时器异常。(错误码:%s)", code));
		this.code = code;
	}

	public JobRunException(StatusEnum status, String... msg) {
		super(String.format("%s(错误码:%s)", status.getValue(), status.getDesc()) + Arrays.toString(msg));
		this.code = status.getValue();
		this.message = status.getDesc() + Arrays.toString(msg);
	}

	public JobRunException(StatusEnum status, Throwable cause) {
		super(String.format("%s(错误码:%s)", status.getValue(), status.getDesc()), cause);
		this.code = status.getValue();
		this.message = status.getDesc();
	}
	
	public JobRunException(String code, String message) {
		super(String.format("%s(错误码:%s)", message, code));
		this.code = code;
		this.message = message;
	}

	public JobRunException(String message, Throwable cause) {
		super(message, cause);
		this.message = message;
	}

	public JobRunException(String code, String message, Throwable cause) {
		super(String.format("%s(错误码:%s)", message, code), cause);
		this.code = code;
		this.message = message;
	}

	public String getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}
	

}
